import BaseModel from '../BaseModel.js';
import brightness from '@ohos.brightness';
import prompt from '@ohos.prompt';

/**
 * brightness service class
 */
export default class BrightnessModel extends BaseModel {
    setBrightness(brightnessValue) {
        try {
            brightness.setValue(brightnessValue);
        } catch (e) {
            console.log("brightness setValue error code: " + e.code + " msg: " + e.message);
            prompt.showToast({
                message: 'code: ' + e.code + ' msg: ' + e.message,
                duration: 10000,
            });
        }
    }

    setBrightnessError() {
        try {
            console.log("brightness setValue string error: ");
            brightness.setValue("");
        } catch (e) {
            console.log("brightness setValue string error code: " + e.code + " msg: " + e.message);
            prompt.showToast({
                message: 'code: ' + e.code + ' msg: ' + e.message,
                duration: 10000,
            });
        }
    }
}